package model;

import java.util.Iterator;

import fpt.com.Product;

public class ProductList extends java.util.ArrayList<Product> implements fpt.com.ProductList {

	private static final long serialVersionUID = -294778288777655448L;
	
	public ProductList(){
		
	}

	@Override
	public boolean delete(Product product) {
		return remove(product);
	}

	@Override
	public Product findProductById(long id) {
		for (Product p : this) {
			long pId = p.getId();
			if(id == pId){
			return p;
			}
		}
		return null;
	}

	@Override
	public Product findProductByName(String name) {
		for (Iterator<Product> i = iterator(); i.hasNext();){
			Product p = i.next();
			String pName = p.getName();
			if(name.equals(pName)){
			return p;
			}
		}
		return null;
	}


}
